package com.ace3l.legal.gwt.domainmodule.gwt;

import com.google.gwt.user.client.rpc.IsSerializable;

import java.util.HashSet;

/**
 * Created by IntelliJ IDEA.
 * User: ageer
 * Date: Jul 18, 2008
 * Time: 9:04:25 PM
 * To change this template use File | Settings | File Templates.
 */
public class GWTUser implements IsSerializable {
    private Integer id;
    private String password;
    private String username;
    private HashSet<GWTRole> roles = new HashSet();

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public HashSet<GWTRole> getGWTRoles() {
        return roles;
    }

    public void setGWTRoles(HashSet<GWTRole> roles) {
        this.roles = roles;
    }

    public void addGWTRole(GWTRole role) {
        role.setUser(this);
        roles.add(role);
    }

    public String getFirstGWTRole() {
        String myGWTRole = roles.iterator().next().getRole();
        return myGWTRole;
    }
    public String toString() {
        return "[" + id + "]"+ username;
    }
}
